# coding=utf8
from django.db import models
from datetime import datetime
from django.contrib.auth.models import AbstractUser


class UserProfile(AbstractUser):
    phone = models.CharField(max_length=11, verbose_name=u"手机号")
    sex = models.IntegerField(verbose_name=u"性别", default=1)
    age = models.IntegerField(verbose_name=u"年龄", default=1)
    years = models.CharField(verbose_name=u"年代", default='00',max_length=3)
    birth = models.CharField(max_length=30, verbose_name=u"出生时间", default='2000-1-1 0:00:00')
    time = models.DateTimeField(default=datetime.now, verbose_name=u"添加时间")
    isDelete = models.BooleanField(verbose_name=u"逻辑删除", default=False)
    show = models.BooleanField(verbose_name=u"显示用户", default=True)

    class Meta:
        verbose_name = u"用户"
        verbose_name_plural = verbose_name

    def __unicode__(self):
        return self.username

    def __str__(self):
        return self.username


class onceName(models.Model):
    user = models.ForeignKey(UserProfile, verbose_name=u"用户")
    name = models.CharField(max_length=10, verbose_name=u"用户名")
    current = models.BooleanField(default=False, verbose_name=u"用户当前用户名")
    time = models.DateTimeField(default=datetime.now, verbose_name=u"添加时间")
    isDelete = models.BooleanField(verbose_name=u"逻辑删除", default=False)
    show = models.BooleanField(verbose_name=u"显示曾用名", default=True)

    class Meta:
        verbose_name = u"曾用名"
        verbose_name_plural = verbose_name

    def __unicode__(self):
        return self.name

    def __str__(self):
        return self.name


class noticeType(models.Model):
    type = models.CharField(max_length=20, verbose_name=u"类型")
    time = models.DateTimeField(default=datetime.now, verbose_name=u"添加时间")
    isDelete = models.BooleanField(verbose_name=u"逻辑删除", default=False)
    show = models.BooleanField(verbose_name=u"显示", default=True)

    class Meta:
        verbose_name = u"通知类型"
        verbose_name_plural = verbose_name

    def __unicode__(self):
        return self.type

    def __str__(self):
        return self.type


class notice(models.Model):
    noticeType = models.ForeignKey(noticeType, verbose_name=u"通知类型")
    user = models.ForeignKey(UserProfile, verbose_name=u"用户", null=True, blank=True)
    secretModel = models.ForeignKey("treehole.secret", verbose_name=u"秘密", null=True, blank=True, related_name="secret_model")
    topicofcModel = models.ForeignKey("treehole.topicofc", verbose_name=u"话题", null=True, blank=True, related_name="topicofc_model")
    noticeContent = models.CharField(max_length=50, verbose_name=u"通知内容")
    replyModel = models.ForeignKey("treehole.comment", verbose_name=u"回复", null=True, blank=True, related_name="reply_model")
    time = models.DateTimeField(default=datetime.now, verbose_name=u"添加时间")
    isDelete = models.BooleanField(verbose_name=u"逻辑删除", default=False)
    show = models.BooleanField(verbose_name=u"显示", default=True)

    class Meta:
        verbose_name = u"通知"
        verbose_name_plural = verbose_name

    def __unicode__(self):
        return self.noticeContent

    def __str__(self):
        return self.noticeContent
